<?php
include("materialinfo.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="js/time.js"></script>
    <script src="jquery.js" ></script>
    <script >
        //添加触发自动计算sum的功能
        function addsum(){
            var num = document.getElementById('num').value;
            var price = document.getElementById('price').value;
                if(isNaN(price) || isNaN(num) || !price || !num){
                    sum = '0';
                    return;
                }
            var sum = parseFloat(price) * parseFloat(num);
            document.getElementById("sum").value = sum;
            }
    </script>
</head>
<body background="../../money/pic/topbg.jpg">
    <table width="98%" height=""  border="0" cellpadding="0" cellspacing="0" >
        <tr>
            <td height="22" valign="top" class="word_orange">当前位置：导航栏&gt;材料入库管理 &gt; &gt; </td>
        </tr>
    </table>
    <br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <table width="82%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" align="center">
                <tr align="center" bgcolor="#e3F4F7">
                <th>材料名称</th>
                <th>单价</th>
                <th>数量</th>
                <th>总金额</th>
                <th>入库时间</th>
                <th>进货人</th>
                <th>供货商</th>
                <th>供货商电话</th>
                <th>供货商开户银行</th>
                <th>供货商银行账号</th>
                <th>操 作</th>
            </tr>
        </thead>

            <form action="material.php" method="post" name="addmaterial" >
                <tr>
                    <td><input id="materialname" name="materialname" size="15"value="<?php echo @$material['materialname'] ?>"></td>
                    <td><input id="price"  name="price" value="<?php  @$_POST['price'] ?>"size="5"></td>
                    <td><input id="num"    name="num"  onchange="addsum()" value="<?php @$_POST['num'] ?>" size="5"></td>
                    <td><input id="sum"    name="sum"   value="<?php echo @$material['sum'] ?>" size="5"></td>
                    <td>
                    <input type="text"name="entertime" value="<?php echo @$material['entertime'] ?>"size="10" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()" readonly="readonly" />
                    </td>
                    <td><input type="text" name="entername" value="<?php echo @$material['entername'] ?>"size="10"/></td>
                    <td><input type="text" name="suppliername" value="<?php echo @$material['suppliername'] ?>"size="15"/></td>
                    <td><input type="text" name="supplierphone" value="<?php echo @$material['supplierphone'] ?>"size="15"/></td>
                    <td><select name="bankname" value="<?php echo @$material['bankname'] ?>" <?php echo  "selected" ?>>
                            <option>--请选择--</option>
                            <option value="中国建设银行" >中国建设银行</option>
                            <option value="中国农业银行 " >中国农业银行</option>
                            <option value="中国工商银行" >中国工商银行</option>
                            <option value="中国招商银行" >中国招商银行</option>
                            <option value="中国农村信用社" >中国农村信用社</option>
                            <option value="中国华夏银行" >中国华夏银行</option>
                        </select>
                    </td>
                    <td><input type="text" name="bankid" value="<?php echo @$material['bankid'] ?>" /></td>
                    <td>
                        <input name="addmaterial" type="submit" value="添加" />
                    </td>
                </tr>
            </form>
             <?php  foreach($materiall as $value){ ?>
            <tr>
                <form action="material.php" method="post" name="updatematerial" >
                    <td><input id="materialname" name="materialname" disabled="disabled" size="15"value="<?php echo $value[0] ?>"></td>
                    <td><input id="pricel"  name="pricel" disabled="disabled" value="<?php echo $value[1] ?>"size="5"></td>
                    <td><input id="numl"    name="numl"   disabled="disabled" value="<?php echo $value[2] ?>"size="5"></td>
                    <td><input id="suml"    name="suml"   disabled="disabled" value="<?php echo $value[10] ?>"size="5"></td>
                    <td><input type="text" name="entertime" disabled="disabled" value="<?php echo $value[3] ?>"size="10"/></td>
                    <td><input type="text" name="entername" disabled="disabled" value="<?php echo $value[4] ?>"size="10"/></td>
                    <td><input type="text" name="suppliername" value="<?php echo $value[5] ?>"size="15"/></td>
                    <td><input type="text" name="supplierphone" value="<?php echo $value[6] ?>"size="15"/></td>
                    <td><input type="text" name="bankname" value="<?php echo $value[8] ?>" size="15"/></td>
                    <td><input type="text" name="bankid" value="<?php echo $value[9] ?>" /></td>
                    <td>
                        <input type="hidden" name="materialId" value="<?php echo $value[7] ?>"/>
                        <input type="submit" name="updatematerial" value="修改" />
                    </td>
                </form>
                <form action="material.php" method="post" name="delmaterial" >
                <td>
                    <input type="hidden" name="materialId" value="<?php echo $value[7] ?>"/>
                    <input type="submit" name="delmaterial" value="删除" />
                </td>
                </form>
            </tr>
            <?php } ?>

    </table>
</table>

    </body>
</html>